{% template "admin/header.html" %}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>组列表</legend>
    </fieldset>
    <div class="">
        <a href="/admin/group/addUI" class="layui-btn layui-btn-sm">添加</a>
    </div>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>

{% template "admin/footer.html" %}
<script type="text/html" id="barDemo">

    {{# if(d.Id!=1){ }}
    <a href="/admin/group/accessUI?id={{d.Id}}" class="layui-btn layui-btn-xs layui-btn-normal">配置规则</a>
    {{# }else{  }}
    <a href="#" class="layui-btn layui-btn-xs layui-btn-disabled">配置规则</a>
    {{# } }}

    <a href="/admin/group/editUI?id={{d.Id}}" class="layui-btn layui-btn-xs">编辑</a>
    {{# if(d.Id==1){ }}
    <a href="#" class="layui-btn layui-btn-xs layui-btn-disabled">删除</a>
    {{# }else{  }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# } }}
</script>

<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        var tableIn = table.render({
            elem: '#list',
            url: '/admin/group/query',
            method:'post',
            where:{},
            cols: [[
                {field:'Id', title: 'ID', width:100}
                ,{field:'Group_name', title: '用户组名', width:150}
                ,{field:'Status', title: '状态', width:150}
                ,{width:200, align:'center', toolbar: '#barDemo'}
            ]]
        });

        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('确认删除吗？', function(index){
                    $.post("/admin/group/delete",{id:data.Id},function(res){
                        if(res.Code==1){
                            layer.msg(res.Msg,{time:1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.Msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });

    });
</script>
</body>
</html>
